// 查询比赛作品列表
import request from '@/utils/request';
import { _Works, Works } from '@/api/model/Works';
import { R } from '@/api/model/R';

export function listWorks(query: _Works): Promise<R<Works>> {
    // eslint-disable-next-line @typescript-eslint/ban-ts-comment
    // @ts-ignore
    return request({
        url: '/business/works/list',
        method: 'get',
        params: query
    });
}


// 查询比赛作品详细
export function getWorks(worksId: number | string): Promise<R<Works>> {
    // eslint-disable-next-line @typescript-eslint/ban-ts-comment
    // @ts-ignore
    return request({
        url: '/business/works/' + worksId,
        method: 'get'
    });
}

// 根据比赛Id查询比赛作品详细
export function getWorksByCompetitionId(competitionId: number | string): Promise<R<Works>> {
    // eslint-disable-next-line @typescript-eslint/ban-ts-comment
    // @ts-ignore
    return request({
        url: `/business/works/byCompetitionId/${competitionId}`,
        method: 'get'
    });
}

// 获取我的作品
export function getMyWorks(query:_Works): Promise<R<Works>> {
    // eslint-disable-next-line @typescript-eslint/ban-ts-comment
    // @ts-ignore
    return request({
        url: `/business/works/my`,
        method: 'get',
        params: query
    });
}


// 新增比赛作品
export function addWorks(data: any) {
    return request({
        url: '/business/works',
        method: 'post',
        data: data
    });
}

// 修改比赛作品
export function updateWorks(data: any) {
    return request({
        url: '/business/works',
        method: 'put',
        data: data
    });
}

// 获取作品提交状态
export function isPublish(competitionId: number | string): Promise<R<boolean>> {
    // eslint-disable-next-line @typescript-eslint/ban-ts-comment
    // @ts-ignore
    return request({
        url: `/business/works/status/${competitionId}`,
        method: 'get'
    });
}

//获取作品排名接口
export function getWorkRankApi(params:any): Promise<R<Works>> {
    // eslint-disable-next-line @typescript-eslint/ban-ts-comment
    // @ts-ignore
    return request({
        url: '/business/works/rank',
        method: 'GET',
        params
    });
}


// 获取需点评的作品
export function getJudgementWorks(query: Works): Promise<R<Works>> {
    // eslint-disable-next-line @typescript-eslint/ban-ts-comment
    // @ts-ignore
    return request({
        url: `/business/works/judgement`,
        method: 'get',
        params: query,
    });
}

